import request from '@/axios';

export const getList = (current, size, params, deptId) => request({
  url: '/zzy-system/user/page',
  method: 'get',
  params: {
    ...params,
    current,
    size,
    deptId,
  },
});

export const remove = ids => request({
  url: '/zzy-system/user/remove',
  method: 'post',
  params: {
    ids,
  },
});

export const add = row => request({
  url: '/zzy-system/user/submit',
  method: 'post',
  data: row,
});

export const update = row => request({
  url: '/zzy-system/user/update',
  method: 'post',
  data: row,
});

export const updatePlatform = (userId, userType, userExt) => request({
  url: '/zzy-system/user/update-platform',
  method: 'post',
  params: {
    userId,
    userType,
    userExt,
  },
});

export const getUser = id => request({
  url: '/zzy-system/user/detail',
  method: 'get',
  params: {
    id,
  },
});

export const getUserPlatform = id => request({
  url: '/zzy-system/user/platform-detail',
  method: 'get',
  params: {
    id,
  },
});

export const getUserInfo = () => request({
  url: '/zzy-system/user/info',
  method: 'get',
});

export const resetPassword = userIds => request({
  url: '/zzy-system/user/reset-password',
  method: 'post',
  params: {
    userIds,
  },
});

export const updatePassword = (oldPassword, newPassword, newPassword1) => request({
  url: '/zzy-system/user/update-password',
  method: 'post',
  params: {
    oldPassword,
    newPassword,
    newPassword1,
  },
});

export const updateInfo = row => request({
  url: '/zzy-system/user/update-info',
  method: 'post',
  data: row,
});

export const grant = (userIds, roleIds) => request({
  url: '/zzy-system/user/grant',
  method: 'post',
  params: {
    userIds,
    roleIds,
  },
});

export const unlock = userIds => request({
  url: '/zzy-system/user/unlock',
  method: 'post',
  params: {
    userIds,
  },
});
